package com.sifang.POI.dianping;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class DpDb {
	
	private static DpDb instance;
	private static Object lock = new Object();
	private SessionFactory sessionFactory;
	
	@SuppressWarnings("deprecation")
	protected  DpDb() {
		Configuration config = new Configuration().configure();
		sessionFactory = config.buildSessionFactory();
	}
	
	public static DpDb getInstance() {
		if (instance == null) {
			synchronized (lock) {
				if (instance == null) {
					instance = new DpDb();
				}
			}
		}
		return instance;
	}
	
	public Session openSession() {
		return this.sessionFactory.openSession();
	}

}
